//
//  DiaryDetailCommentView.swift
//  MyDiary2025
//
//  Created by 罗万能 on 2025/6/27.
//

import SwiftUI

struct DiaryDetailCommentView: View {
    var diary: DiaryModel
    var body: some View {
        VStack(alignment: .leading){
            Text("日后心情")
                .font(.headline)
                .foregroundStyle(.title)
                .padding(.bottom,7)
            ForEach(diary.comment.sorted(by: { $0.date > $1.date })){commet in
                ZStack(alignment: .leading){
                    RoundedRectangle(cornerRadius: 12)
                        .foregroundStyle(.back)
                        .shadow(radius: 3)
                        
                    VStack(alignment: .leading) {
                        Text(commet.content)
                            .font(.body)
                            .foregroundStyle(.body)
                            .padding(.bottom,2)
                        Text("\(commet.date.viewDate)")
                            .font(.footnote)
                            .foregroundStyle(.warning)
                        
                    }.padding()
                }
                
                
            }
        }
    }
}

#Preview {
    DiaryDetailCommentView(diary: DiaryModel.debugData)
}
